package be.pluyckx.batteryprogress.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

import be.pluyckx.batteryprogress.R;
import be.pluyckx.batteryprogress.activity.fragment.settings.FileStoreSettingsFragment;
import be.pluyckx.batteryprogress.activity.fragment.settings.HistorySettings;
import be.pluyckx.batteryprogress.activity.fragment.settings.RealTimeSettingsFragment;

/**
 * Created by Philip Luyckx on 11/08/13.
 *
 * The Settings Activity.
 */
public class SettingsActivity extends FragmentActivity {
  private static final String TAG_FRAGMENT_RT_SETTINGS = "RealtimeSettings";
  private static final String TAG_FRAGMENT_FILE_SETTINGS = "FileSettings";
  private static final String TAG_FRAGMENT_HISTORY_SETTINGS = "HistorySettings";

  @Override
  protected void onDestroy() {
    super.onDestroy();
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_settings);

    setTitle(R.string.app_name);

    Fragment fragment = null;

    if (getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT_RT_SETTINGS) == null && findViewById(R.id.container_real_time_settings) != null) {
      fragment = new RealTimeSettingsFragment();
      getSupportFragmentManager().beginTransaction().add(R.id.container_real_time_settings, fragment, TAG_FRAGMENT_RT_SETTINGS).commit();
    }

    if (getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT_HISTORY_SETTINGS) == null && findViewById(R.id.container_history_settings) != null) {
      fragment = new HistorySettings();
      getSupportFragmentManager().beginTransaction().add(R.id.container_history_settings, fragment, TAG_FRAGMENT_HISTORY_SETTINGS).commit();
    }

    if (getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT_FILE_SETTINGS) == null && findViewById(R.id.container_file_settings) != null) {
      fragment = new FileStoreSettingsFragment();
      getSupportFragmentManager().beginTransaction().add(R.id.container_file_settings, fragment, TAG_FRAGMENT_FILE_SETTINGS).commit();
    }
  }
}
